/*
//  Controller.h
//  Agate Rule Tester
//
//  Created by Jim Turner on 11/20/05.

License: GNU General Public License
This program is free software; you can redistribute it and/or modify it under 
the terms of the GNU General Public License as published by the Free Software 
Foundation; either version 2 of the License, or (at your option) any later 
version.

This program is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 
details.

You should have received a copy of the GNU General Public License along 
with this program; if not, write to the Free Software Foundation, Inc., 
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
http://www.gnu.org/licenses/licenses.html#GPL

*/

#import <Cocoa/Cocoa.h>
#import "JTFileData.h"
#import "JTPerlInterface.h"

@interface Controller : NSObject
{
    IBOutlet id controlWindow;
    IBOutlet id errorText;
    IBOutlet id errorWindow;
    IBOutlet id outputWindow;
	IBOutlet id ruleWindow;
    IBOutlet id ruleTable;
    IBOutlet id translationTextView;
	IBOutlet id findStringTextView;
	IBOutlet id replaceStringTextView;
	IBOutlet id baseTranslationStatus;
	IBOutlet id regexTestError;
	IBOutlet id menuNewTranslation;
	IBOutlet id menuNewTranslationWithCurrentBase;
	IBOutlet id showDTMnemonicsCheckbox;
	IBOutlet id placeRuleWhereDropdown;
	IBOutlet id check_caseSensitiveSearch;
	IBOutlet id check_exhaustiveReplace;
	IBOutlet id check_replaceFirstOnly;
	IBOutlet id check_replaceLastOnly;
	IBOutlet id check_usePerlExpressions;
	IBOutlet id translationInformation;
	IBOutlet id asciiError;
	
	NSMutableArray  *ruleList;
	NSMutableArray  *baseRuleList;
	JTFileData      *fileData;

	// These keep track of where we lasted saved and opened things
	NSMutableString *savedTranslationPath;
	NSMutableString *savedTranslatedTextPath;
	NSMutableString *savedLastOpenPath;
	
	// An instance of perl
	JTPerlInterface *perl;
}

#pragma mark Error Handling
- (IBAction)cancelError:(id)sender;
- (IBAction)okError:(id)sender;

#pragma mark File Handling
- (IBAction)openFile:(id)sender;
- (IBAction)saveFile:(id)sender;
- (IBAction)newTranslation:(id)sender;

#pragma mark Rule Manipulation
- (IBAction)newRule:(id)sender;
- (IBAction)deleteRule:(id)sender;
- (IBAction)duplicateRule:(id)sender;
- (IBAction)editRule:(id)sender;
- (IBAction)saveRule:(id)sender;
- (IBAction)cancelSaveRule:(id)sender;
- (IBAction)moveRuleDown:(id)sender;
- (IBAction)moveRuleUp:(id)sender;
- (IBAction)ruleActiveStatusClicked:(id)sender;
- (IBAction)ruleToggleAllRules:(id)sender;
- (IBAction)runRules:(id)sender;
- (void)updateRuleOrders:(int)savePosition;

#pragma mark Hidden Character Handling
- (IBAction)showDTMnemonics:(id)sender;

#pragma mark Extra Window handling
- (void) openPanelDidEnd:(NSOpenPanel *)sheet returnCode:(int)returnCode  contextInfo:(void *)contextInfo;
- (void) savePanelDidEnd:(NSSavePanel *)sheet returnCode:(int)returnCode  contextInfo:(void *)contextInfo;
- (void) sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo;
- (void) updateTextView:(NSString *)newText;

#pragma mark Debugging routines
- (IBAction) dumpRuleList:(id)sender;

#pragma mark NSTableView items
- (IBAction) tableDoubleClicked:(id)sender;

#pragma mark Other Interface Items

@end
